package com.want.repository;

import com.want.models.entity.User;
import org.springframework.data.domain.Pageable;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
 * @author WangZhiJian
 * @since 2021/11/21
 */
@Repository
public interface UserRepository extends ReactiveSortingRepository<User, Integer> {
    Mono<User> findByEmail(String email);

    Mono<Void> deleteByEmail(String email);

    @Query("select * from user limit :index,:size")
    Flux<User> findUserCustom(Integer index,Integer size);

    // 分页
    Flux<User> findUserByIdGreaterThan(Integer id,Pageable pageable);

//    /**
//     * 根据用户的email和密码进行登录
//     * @param email
//     * @param password
//     * @return
//     */
//    Mono<User> findUserByEmailAndPassword(String email, String password);
}
